|
@@ -26,6 +26,8 @@ import com.ruoyi.system.service.ISysDictDataService;
|
|
|
import com.ruoyi.warehouseBusiness.service.impl.BillnoSerialServiceImpl;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
@@ -98,7 +100,10 @@ public class FTmsaccbillsServiceImpl implements IFTmsaccbillsService
|
|
|
// 主表数
|
|
|
Ftmsorderbills ftmsorderbills = ftmsorderbillsMapper.selectftmsorderbillsById(fees.getfSrcpid());
|
|
|
Ftmsorderbillsfees ftmsorderbillsfees = ftmsorderbillsfeesMapper.selectFTmsorderbillsfeesById(fees.getfSrcid());
|
|
|
- TFees tFees= tFeesMapper.selectTFeesById(ftmsorderbillsfees.getfFeeid());
|
|
|
+ TFees tFees = new TFees();
|
|
|
+ if(null!=ftmsorderbillsfees.getfFeeid()){
|
|
|
+ tFees= tFeesMapper.selectTFeesById(ftmsorderbillsfees.getfFeeid());
|
|
|
+ }
|
|
|
// 字典宝
|
|
|
SysDictData sysDictData =new SysDictData();
|
|
|
sysDictData.setDictType("data_unitfees");
|
|
@@ -117,7 +122,11 @@ public class FTmsaccbillsServiceImpl implements IFTmsaccbillsService
|
|
|
map1.put("createTime",ftmsorderbillsfees.getCreateTime()); //业务日期
|
|
|
map1.put("actId",ftmsorderbillsfees.getActId()); // 业务类型
|
|
|
map1.put("billType",ftmsorderbills.getBillType()); // 作业类型
|
|
|
- map1.put("fFeeName",tFees.getfName()); // 作业类型
|
|
|
+ if(null!=tFees.getfName()){
|
|
|
+ map1.put("fFeeName",tFees.getfName()); // 作业类型
|
|
|
+ }else {
|
|
|
+ map1.put("fFeeName",null); // 作业类型
|
|
|
+ }
|
|
|
feesId.add(ftmsorderbillsfees.getfFeeunitid());
|
|
|
map1.put("fSrcdc",fees.getDc()); // 收付
|
|
|
map1.put("fAmt",fees.getAmtOrg()); // 数量
|
|
@@ -284,4 +293,89 @@ public class FTmsaccbillsServiceImpl implements IFTmsaccbillsService
|
|
|
return AjaxResult.success("2");
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public AjaxResult confirm(String tfee, String tfeeDo, LoginUser loginUser, String fBilltype) {
|
|
|
+ FTmsaccbills fTmsaccbills = JSONArray.parseObject(tfee, FTmsaccbills.class);
|
|
|
+ fTmsaccbills.setBillStatus(4L);
|
|
|
+ if (StringUtils.isNull(fTmsaccbills.getId())) {
|
|
|
+ // 如果是新数据
|
|
|
+ fTmsaccbills.setCreateBy(loginUser.getUser().getUserName());
|
|
|
+ fTmsaccbills.setCreateTime(new Date());
|
|
|
+ // 业务编码
|
|
|
+ Date time = new Date();
|
|
|
+ String billNo = billnoSerialServiceImpl.getBillNo(fBilltype, time);
|
|
|
+ fTmsaccbills.setfBillno(billNo);
|
|
|
+ fTmsaccbills.setfBilltype(fBilltype);
|
|
|
+ fTmsaccbillsMapper.insertFTmsaccbills(fTmsaccbills);
|
|
|
+ } else {
|
|
|
+ fTmsaccbills.setUpdateBy(loginUser.getUser().getUserName());
|
|
|
+ fTmsaccbills.setUpdateTime(new Date());
|
|
|
+ fTmsaccbillsMapper.updateFTmsaccbills(fTmsaccbills);
|
|
|
+ // 删除从表
|
|
|
+ fTmsaccbillsitemsMapper.deleteByFPid(fTmsaccbills.getId());
|
|
|
+ }
|
|
|
+ // 财务从表
|
|
|
+ if (StringUtils.isNotNull(tfeeDo)) {
|
|
|
+ JSONArray jsonDrArray = JSONArray.parseArray(tfeeDo);
|
|
|
+ List<FTmsaccbillsitems> tFeeDoList = JSONObject.parseArray(jsonDrArray.toJSONString(), FTmsaccbillsitems.class);
|
|
|
+ for (FTmsaccbillsitems tFeeDo : tFeeDoList) {
|
|
|
+ tFeeDo.setSrcId(fTmsaccbills.getId());
|
|
|
+ tFeeDo.setCreateBy(loginUser.getUser().getUserName());
|
|
|
+ tFeeDo.setCreateTime(new Date());
|
|
|
+ fTmsaccbillsitemsMapper.insertFTmsaccbillsitems(tFeeDo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotNull(tfeeDo) && !"[]".equals(tfeeDo)) {
|
|
|
+ JSONArray jsonDrArray = JSONArray.parseArray(tfeeDo);
|
|
|
+ List<FTmsaccbillsitems> tFeeDoList = JSONObject.parseArray(jsonDrArray.toJSONString(), FTmsaccbillsitems.class);
|
|
|
+ for (FTmsaccbillsitems tFeeDo : tFeeDoList) {
|
|
|
+ // 跟新费用明细
|
|
|
+ int m = updateBillsFees(fTmsaccbills.getId(),tFeeDo,fBilltype);
|
|
|
+ if (m == 0) {
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return AjaxResult.error("更新费用明细失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ AjaxResult ajaxResult = tfeeFollow(fTmsaccbills.getId(), 6L);
|
|
|
+ Long code = Long.valueOf(String.valueOf(ajaxResult.get("code"))).longValue();
|
|
|
+ return ajaxResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ public int updateBillsFees(Long fid,FTmsaccbillsitems tFeeDo,String billsType){
|
|
|
+ // 查询从表数据
|
|
|
+ FTmsaccbills tFee = fTmsaccbillsMapper.selectFTmsaccbillsById(fid);
|
|
|
+ if(billsType.equals("JSSF") || billsType.equals("JSFF")){
|
|
|
+ billsType="DC";
|
|
|
+ }
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("tFee", tFee);
|
|
|
+ map.put("billType", billsType);
|
|
|
+ map.put("tFeeDo", tFeeDo);
|
|
|
+ return ftmsorderbillsfeesMapper.updateFTmsorderbillsfee(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ public AjaxResult tfeeFollow(Long fPid, long fettle) {
|
|
|
+ if (StringUtils.isNull(fPid)) {
|
|
|
+ return AjaxResult.error("财务更新状态未找到主表信息,请与管理员联系");
|
|
|
+ }
|
|
|
+ FTmsaccbills tFee = new FTmsaccbills();
|
|
|
+ tFee.setId(fPid);
|
|
|
+ tFee.setBillStatus(fettle);
|
|
|
+ int tFeeUpdateResult = fTmsaccbillsMapper.updateFTmsaccbills(tFee);
|
|
|
+ if (tFeeUpdateResult <= 0) {
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return AjaxResult.error("更新财务明细状态失败,请联系管理员");
|
|
|
+ }
|
|
|
+ try{
|
|
|
+ int itemUpdateResult = fTmsaccbillsitemsMapper.tfeeDoFollowUpdate(fPid,fettle);
|
|
|
+ } catch (Exception exception){
|
|
|
+ return AjaxResult.error("更新财务明细状态失败,请联系管理员");
|
|
|
+ }
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
}
|