| | |
| | | import com.yeshi.fanli.service.inter.homemodule.SpecialCardService;
|
| | | import com.yeshi.fanli.service.inter.homemodule.SpecialPlaceService;
|
| | | import com.yeshi.fanli.service.inter.homemodule.SpecialService;
|
| | | import com.yeshi.fanli.util.FilePathEnum;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | |
|
| | | @Service
|
| | |
| | | }
|
| | |
|
| | | // 时间任务控制
|
| | | conversionTime(record);
|
| | | handleTime(record);
|
| | |
|
| | |
|
| | | // 图片上传
|
| | |
| | |
|
| | | /**
|
| | | * web段时间转换
|
| | | * |
| | | * @param record
|
| | | */
|
| | | public void conversionTime(SpecialCard record) throws SpecialCardException, Exception {
|
| | | // 是否时间控制
|
| | | if(!record.isTimeTask()) {
|
| | | record.setStartTime(null);
|
| | | record.setEndTime(null);
|
| | | } else {
|
| | | String startTime_str = record.getStartTime_str();
|
| | | String endTime_str = record.getEndTime_str();
|
| | | |
| | | if ((startTime_str == null|| startTime_str.trim().length() == 0) |
| | | && (endTime_str == null || endTime_str.trim().length() == 0)) {
|
| | | throw new SpecialCardException(1, "请输入控制时间");
|
| | | } else {
|
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
| | | if (startTime_str != null && startTime_str.trim().length() > 0) {
|
| | | startTime_str = startTime_str.replaceAll("T", " ");
|
| | | record.setStartTime(format.parse(startTime_str));
|
| | | }
|
| | | |
| | | if (endTime_str != null && endTime_str.trim().length() > 0) {
|
| | | endTime_str = endTime_str.replaceAll("T", " ");
|
| | | record.setEndTime(format.parse(endTime_str));
|
| | | }
|
| | | }
|
| | | private void handleTime(SpecialCard record) throws SpecialCardException, Exception {
|
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
| | | |
| | | String startTime_str = record.getStartTime_str();
|
| | | if (!StringUtil.isNullOrEmpty(startTime_str)) {
|
| | | startTime_str = startTime_str.replaceAll("T", " ");
|
| | | record.setStartTime(format.parse(startTime_str));
|
| | | }
|
| | | |
| | | String endTime_str = record.getEndTime_str();
|
| | | if (!StringUtil.isNullOrEmpty(endTime_str)) {
|
| | | endTime_str = endTime_str.replaceAll("T", " ");
|
| | | record.setEndTime(format.parse(endTime_str));
|
| | | }
|
| | | |
| | | if (record.getEndTime() != null && record.getStartTime() != null
|
| | | && record.getStartTime().getTime() > record.getEndTime().getTime()) {
|
| | | throw new SpecialCardException(1, "起始时间不能小于结束时间");
|
| | | }
|
| | | }
|
| | |
|
| | | |
| | |
|
| | | /**
|
| | | * 上传图片
|
| | |
| | | String type = contentType.substring(contentType.indexOf("/") + 1);
|
| | |
|
| | | // 文件路径
|
| | | String filePath="/img/SpecialCard/"+UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | String filePath=FilePathEnum.specialCard.getPath() +UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | // 执行上传
|
| | | String fileLink= COSManager.getInstance().uploadFile(inputStream, filePath).getUrl();
|
| | |
|
| | |
| | | long totalSpecial= specialService.countlistQueryByCard(specialCard.getId(), null, null);
|
| | | specialCard.setTotalSpecial(totalSpecial);
|
| | |
|
| | | // 将状态变化
|
| | | if (specialCard.getState() != null && specialCard.getState() == 0) {
|
| | | specialCard.setState(1);
|
| | | } else {
|
| | | specialCard.setState(0);
|
| | | }
|
| | | |
| | | |
| | | Date startTime = specialCard.getStartTime();
|
| | | Date endTime = specialCard.getEndTime();
|
| | | if (startTime == null && endTime == null) {
|
| | | specialCard.setTimeTask(false);
|
| | | specialCard.setStartTime_str("");
|
| | | specialCard.setEndTime_str("");
|
| | | } else {
|
| | | specialCard.setTimeTask(true);
|
| | | |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm");
|
| | | if (startTime == null) {
|
| | | specialCard.setStartTime_str("");
|
| | |
| | | specialCard.setPlaceName(specialPlace.getName());
|
| | | }
|
| | | }
|
| | | |
| | | }
|
| | | |
| | | return listObj;
|
| | | }
|
| | |
|
| | |
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | | public void switchState(Long id) throws SpecialCardException {
|
| | | if (id == null) {
|
| | | throw new SpecialCardException(1, "请传递正确参数");
|
| | | }
|
| | | |
| | | SpecialCard resultObj = specialCardMapper.selectByPrimaryKey(id);
|
| | | if (resultObj == null) {
|
| | | throw new SpecialCardException(1, "此内容已不存在");
|
| | | }
|
| | | |
| | | Integer state = resultObj.getState();
|
| | | if (state == null || state == 0) {
|
| | | state = 1;
|
| | | } else {
|
| | | state = 0;
|
| | | }
|
| | | |
| | | SpecialCard updateObj = new SpecialCard();
|
| | | updateObj.setId(id);
|
| | | updateObj.setState(state);
|
| | | specialCardMapper.updateByPrimaryKeySelective(updateObj);
|
| | | }
|
| | |
|
| | |
|
| | | }
|