Commit d83edebffa4a0bab26ce45787a898791cbbce66a

Authored by 房远帅
1 parent 47340545

楚江ERP:客户资信-核心人员每年1月1日年龄自动+1

... ... @@ -20,6 +20,7 @@ import io.swagger.annotations.ApiOperation;
20 20 import com.lframework.starter.common.utils.CollectionUtil;
21 21 import io.swagger.annotations.Api;
22 22 import org.springframework.beans.factory.annotation.Autowired;
  23 +import org.springframework.scheduling.annotation.Scheduled;
23 24 import org.springframework.validation.annotation.Validated;
24 25 import org.springframework.web.bind.annotation.*;
25 26
... ... @@ -106,4 +107,14 @@ public class CorePersonnelController extends DefaultBaseController {
106 107
107 108 return InvokeResultBuilder.success();
108 109 }
  110 +
  111 + @Scheduled(cron = "0 0 0 1 1 ?")
  112 + @ApiOperation("自动更新年龄")
  113 + @GetMapping("/updateAge")
  114 + public InvokeResult<Void> updateAge() {
  115 +
  116 + corePersonnelService.updateAge();
  117 +
  118 + return InvokeResultBuilder.success();
  119 + }
109 120 }
... ...
... ... @@ -17,6 +17,7 @@ import com.lframework.starter.common.exceptions.impl.DefaultClientException;
17 17 import io.swagger.annotations.ApiOperation;
18 18 import com.lframework.starter.common.utils.CollectionUtil;
19 19 import io.swagger.annotations.Api;
  20 +import org.springframework.scheduling.annotation.Scheduled;
20 21 import org.springframework.web.bind.annotation.DeleteMapping;
21 22 import org.springframework.beans.factory.annotation.Autowired;
22 23 import org.springframework.validation.annotation.Validated;
... ... @@ -106,4 +107,14 @@ public class CorePersonnelHistoryController extends DefaultBaseController {
106 107
107 108 return InvokeResultBuilder.success();
108 109 }
  110 +
  111 + @Scheduled(cron = "0 0 0 1 1 ?")
  112 + @ApiOperation("自动更新年龄")
  113 + @GetMapping("/updateAge")
  114 + public InvokeResult<Void> updateAge() {
  115 +
  116 + corePersonnelHistoryService.updateAge();
  117 +
  118 + return InvokeResultBuilder.success();
  119 + }
109 120 }
... ...
... ... @@ -242,6 +242,15 @@ public class CorePersonnelHistoryServiceImpl extends BaseMpServiceImpl<CorePerso
242 242 return data;
243 243 }
244 244
  245 + @OpLog(type = OtherOpLogType.class, name = "年龄自动+1,ID:{}", params = {"#id"})
  246 + @Transactional(rollbackFor = Exception.class)
  247 + @Override
  248 + public void updateAge() {
  249 +
  250 + getBaseMapper().updateAge();
  251 + }
  252 +
  253 +
245 254 @CacheEvict(value = CorePersonnelHistory.CACHE_NAME, key = "@cacheVariables.tenantId() + #key")
246 255 @Override
247 256 public void cleanCacheByKey(Serializable key) {
... ...
... ... @@ -146,6 +146,14 @@ public class CorePersonnelServiceImpl extends BaseMpServiceImpl<CorePersonnelMap
146 146 getBaseMapper().deleteById(id);
147 147 }
148 148
  149 + @OpLog(type = OtherOpLogType.class, name = "年龄自动+1,ID:{}", params = {"#id"})
  150 + @Transactional(rollbackFor = Exception.class)
  151 + @Override
  152 + public void updateAge() {
  153 +
  154 + getBaseMapper().updateAge();
  155 + }
  156 +
149 157 @CacheEvict(value = CorePersonnel.CACHE_NAME, key = "@cacheVariables.tenantId() + #key")
150 158 @Override
151 159 public void cleanCacheByKey(Serializable key) {
... ...
... ... @@ -21,4 +21,6 @@ public interface CorePersonnelHistoryMapper extends BaseMapper<CorePersonnelHist
21 21 * @return
22 22 */
23 23 List<CorePersonnelHistory> query(@Param("vo") QueryCorePersonnelHistoryVo vo);
  24 +
  25 + void updateAge();
24 26 }
... ...
... ... @@ -25,4 +25,6 @@ public interface CorePersonnelMapper extends BaseMapper<CorePersonnel> {
25 25 * @return
26 26 */
27 27 List<CorePersonnel> query(@Param("vo") QueryCorePersonnelVo vo);
  28 +
  29 + void updateAge();
28 30 }
... ...
... ... @@ -57,4 +57,6 @@ public interface CorePersonnelHistoryService extends BaseMpService<CorePersonnel
57 57 void updateWithChangeInfo(List<CorePersonnelHistory> beforeList, List<CorePersonnelHistory> afterList);
58 58
59 59 CorePersonnelHistory changeCorePersonnel(CorePersonnel vo);
  60 +
  61 + void updateAge();
60 62 }
... ...
... ... @@ -53,4 +53,6 @@ public interface CorePersonnelService extends BaseMpService<CorePersonnel> {
53 53 */
54 54 void deleteById(String id);
55 55
  56 + void updateAge();
  57 +
56 58 }
... ...
... ... @@ -59,4 +59,10 @@
59 59 </if>
60 60 </where>
61 61 </select>
  62 +
  63 + <update id="updateAge">
  64 + UPDATE core_personnel
  65 + SET age = CAST(age AS UNSIGNED) + 1
  66 + WHERE age REGEXP '^[0-9]+$';
  67 + </update>
62 68 </mapper>
... ...
... ... @@ -60,4 +60,9 @@
60 60 </if>
61 61 </where>
62 62 </select>
  63 + <update id="updateAge">
  64 + UPDATE core_personnel
  65 + SET age = CAST(age AS UNSIGNED) + 1
  66 + WHERE age REGEXP '^[0-9]+$';
  67 + </update>
63 68 </mapper>
... ...