|
|
@@ -21,14 +21,13 @@ import com.usoftchina.saas.finance.api.VoucherApi;
|
|
|
import com.usoftchina.saas.page.PageDefault;
|
|
|
import com.usoftchina.saas.page.PageRequest;
|
|
|
import com.usoftchina.saas.storage.api.StockProdInOutApi;
|
|
|
-import com.usoftchina.saas.util.JsonUtils;
|
|
|
+import com.usoftchina.saas.util.DateUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
@@ -165,10 +164,9 @@ public class ConfigsServiceImpl implements ConfigsService{
|
|
|
//初始化期间
|
|
|
int initperiod=endProductService.getInitPeriod(BaseContextHolder.getCompanyId());
|
|
|
//当前日期年月
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyyMM");
|
|
|
- String nowyearmonth = sdf.format(new Date());
|
|
|
+ int nowPeriod = DateUtils.getYearmonth();
|
|
|
//只能在初始化期间修改本位币
|
|
|
- if(Integer.parseInt(nowyearmonth)!=initperiod){
|
|
|
+ if(nowPeriod != initperiod){
|
|
|
throw new BizException(BizExceptionCode.BIZ_CURRENCY_INIT.getCode(),BizExceptionCode.BIZ_CURRENCY_INIT.getMessage());
|
|
|
}
|
|
|
//检查初始化期间是否已结账
|
|
|
@@ -254,12 +252,16 @@ public class ConfigsServiceImpl implements ConfigsService{
|
|
|
// }
|
|
|
// }
|
|
|
//参数配置不存在则生成对应参数配置
|
|
|
- int num = configsMapper.updateByCodeSelective(con);
|
|
|
- if(num == 0){
|
|
|
+ int existsCount = configsMapper.countByCodeAndCompanyId(con.getCode(), con.getCompanyId());
|
|
|
+ if (existsCount == 0){
|
|
|
con.setCreatorId(BaseContextHolder.getUserId());
|
|
|
con.setCreateTime(new Date());
|
|
|
con.setCreatorName(BaseContextHolder.getUserName());
|
|
|
configsMapper.insertSelective(con);
|
|
|
+ } else {
|
|
|
+ // 注意,不要用updateByCodeSelective的返回值来判断是否存在。
|
|
|
+ // 当update的数据与原数据一样的时候,是不会更新的,返回值也是0,此时不要做新增操作
|
|
|
+ configsMapper.updateByCodeSelective(con);
|
|
|
}
|
|
|
}
|
|
|
DocBaseDTO baseDTO = new DocBaseDTO(null, "", "Configs");
|