Antiloveg 8 роки тому
батько
коміт
6da28b8e82

+ 7 - 43
src/main/java/com/goafanti/demand/service/impl/DemandServiceImpl.java

@@ -9,17 +9,16 @@ import java.util.Map;
 import java.util.UUID;
 
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import com.goafanti.common.constant.AFTConstants;
-import com.goafanti.common.dao.DemandLogMapper;
 import com.goafanti.common.dao.DemandMapper;
 import com.goafanti.common.enums.DeleteStatus;
 import com.goafanti.common.enums.DemandReleaseStatus;
 import com.goafanti.common.enums.DemandStatus;
 import com.goafanti.common.model.Demand;
-import com.goafanti.common.model.DemandLog;
 import com.goafanti.common.utils.DateUtils;
 import com.goafanti.core.mybatis.BaseMybatisDao;
 import com.goafanti.core.mybatis.page.Pagination;
@@ -32,8 +31,6 @@ import com.goafanti.demand.service.DemandService;
 public class DemandServiceImpl extends BaseMybatisDao<DemandMapper> implements DemandService {
 	@Autowired
 	private DemandMapper	demandMapper;
-	@Autowired
-	private DemandLogMapper	demandLogMapper;
 
 	@SuppressWarnings("unchecked")
 	@Override
@@ -277,19 +274,12 @@ public class DemandServiceImpl extends BaseMybatisDao<DemandMapper> implements D
 
 		Calendar now = Calendar.getInstance();
 		now.set(Calendar.MILLISECOND, 0);
-
+		d.setStatus(DemandStatus.CREATE.getCode());
 		if (DemandReleaseStatus.RELEASED.getCode().equals(d.getReleaseStatus())) {
 			d.setReleaseDate(now.getTime());
 			d.setStatus(DemandStatus.ONGOING.getCode());
-			DemandLog log = new DemandLog();
-			log.setId(UUID.randomUUID().toString());
-			log.setDemandId(d.getId());
-			log.setStatus(d.getStatus());
-			log.setRecoredTime(now.getTime());
-			log.setOperator(TokenManager.getAdminId());
-			demandLogMapper.insert(log);
 		}
-		d.setStatus(DemandStatus.CREATE.getCode());
+		
 		d.setCreateTime(now.getTime());
 		demandMapper.insert(d);
 	}
@@ -314,43 +304,17 @@ public class DemandServiceImpl extends BaseMybatisDao<DemandMapper> implements D
 				&& DemandReleaseStatus.UNRELEASE.getCode().equals(demand.getReleaseStatus())) {
 			d.setReleaseDate(now.getTime());
 			d.setStatus(DemandStatus.ONGOING.getCode());
-			DemandLog log = new DemandLog();
-			log.setId(UUID.randomUUID().toString());
-			log.setDemandId(d.getId());
-			log.setStatus(d.getStatus());
-			log.setRecoredTime(now.getTime());
-			log.setOperator(TokenManager.getAdminId());
-			demandLogMapper.insert(log);
 		}
 
 		if (DemandReleaseStatus.UNRELEASE.getCode().equals(d.getReleaseStatus())
 				&& DemandReleaseStatus.RELEASED.getCode().equals(demand.getReleaseStatus())) {
-			d.setReleaseDate(now.getTime());
 			d.setStatus(DemandStatus.CREATE.getCode());
-			DemandLog log = new DemandLog();
-			log.setId(UUID.randomUUID().toString());
-			log.setDemandId(d.getId());
-			log.setStatus(d.getStatus());
-			log.setRecoredTime(now.getTime());
-			log.setOperator(TokenManager.getAdminId());
-			demandLogMapper.insert(log);
-		}
-
-		if (DemandReleaseStatus.RELEASED.getCode().equals(d.getReleaseStatus())
-				&& (DemandStatus.SOLVED.equals(d.getStatus()) || DemandStatus.UNRESOLVED.equals(d.getStatus()))) {
-			DemandLog log = new DemandLog();
-			log.setId(UUID.randomUUID().toString());
-			log.setDemandId(d.getId());
-			log.setStatus(d.getStatus());
-			log.setRecoredTime(now.getTime());
-			log.setOperator(TokenManager.getAdminId());
-			demandLogMapper.insert(log);
+			d.setValidityPeriod(null);
 		}
 		
-		if (!DemandStatus.SOLVED.equals(d.getStatus()) && !DemandStatus.UNRESOLVED.equals(d.getStatus())){
-			d.setStatus(null);
-		}
-		return demandMapper.updateByPrimaryKeySelective(d);
+		BeanUtils.copyProperties(d, demand);
+		
+		return demandMapper.updateByPrimaryKey(demand);
 	}
 
 	@Override